/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/

package zblibrary.facechat.modules.lookinggood.view;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;

import zblibrary.facechat.R;
import zblibrary.facechat.entity.LookingGoodEntity;
import zblibrary.facechat.entity.LookingGoodEntity;
import zuo.biao.library.base.BaseModel;
import zuo.biao.library.base.BaseView;
import zuo.biao.library.util.CommonUtil;

public class LookingGoodItemView extends BaseView<LookingGoodEntity> implements OnClickListener {
	private static final String TAG = "FoundItemView";
	public LookingGoodItemView(Activity context, ViewGroup parent) {
		super(context, R.layout.found_good_item, parent);
	}

	public ImageView found_user_img;
	public TextView found_user_name;
	public TextView found_time;
	public TextView found_status;

	public TextView found_item_content;
	public RecyclerView found_item_pic_recycler_view;

	@SuppressLint("InflateParams")
	@Override
	public View createView() {
		found_user_img = (ImageView) findViewById(R.id.found_user_img);
		found_user_name = (TextView) findViewById(R.id.found_user_name);
		found_time = (TextView) findView(R.id.found_time);
		found_status = (TextView) findViewById(R.id.found_status);
		found_item_content = (TextView) findViewById(R.id.found_item_content);
		found_item_pic_recycler_view = (RecyclerView) findViewById(R.id.found_item_pic_recycler_view);

		return super.createView();
	}

	@Override
	public void bindView(LookingGoodEntity data_){
		super.bindView(data_ != null ? data_ : new LookingGoodEntity());

		Glide.with(context).asBitmap().load(data.getUser().getAvatar()).into(new SimpleTarget<Bitmap>() {
			@Override
			public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
				found_user_img.setImageBitmap(CommonUtil.toRoundCorner(bitmap, 4));
			}
		});

		found_user_name.setText(data.getUser().getUsername());
		found_time.setText("2022-04-22");
		found_status.setText("寻找中");
	}

	@Override
	public void onClick(View v) {
		if (BaseModel.isCorrect(data) == false) {
			return;
		}
		switch (v.getId()) {
			case R.id.discuss_pic: {
				showShortToast("再按一次退出");
				break;
			}
			case R.id.discuss_title: {
				showShortToast("点击了Title");
				break;
			}
			case R.id.discuss_user_id: {
				showShortToast("点击了Phone");
				break;
			}
			default:
				break;
		}
	}
}